/*******************************************************************************
 * Copyright (c) 2017 Red Hat, Inc. 
 * Distributed under license by Red Hat, Inc. All rights reserved. 
 * This program is made available under the terms of the 
 * Eclipse Public License v1.0 which accompanies this distribution, 
 * and is available at https://www.eclipse.org/legal/epl-v10.html 
 * 
 * Contributors: 
 * Red Hat, Inc. - initial API and implementation
 ******************************************************************************/
/** 
 * This class 'FuseJMXNewConnectionWizard.java' was generated by RedDeer Code Generator. 
 * Selected options:
 *		Getter
 *		Setter
 *		Action method
 *		Generate static constants
 *		Include all wizard pages
 *		Allow inheriting (only, if are included all wizard pages)
 */
package org.jboss.tools.fuse.reddeer.wizard;

import org.eclipse.reddeer.common.wait.WaitUntil;
import org.eclipse.reddeer.jface.wizard.WizardDialog;
import org.eclipse.reddeer.swt.condition.ShellIsAvailable;
import org.eclipse.reddeer.swt.impl.button.CheckBox;
import org.eclipse.reddeer.swt.impl.button.PushButton;
import org.eclipse.reddeer.swt.impl.button.RadioButton;
import org.eclipse.reddeer.swt.impl.shell.DefaultShell;
import org.eclipse.reddeer.swt.impl.text.LabeledText;
import org.eclipse.reddeer.swt.impl.tree.DefaultTree;
import org.eclipse.reddeer.swt.impl.tree.DefaultTreeItem;

/**
 * Represents <i>JMX New Connection</i> dialog that is displayed after click on <i>New Connection...</i> button in
 * <i>JMX Navigator</i> view.
 * 
 * @author djelinek
 */
public class JMXNewConnectionWizard extends WizardDialog {
	
	private static String TITTLE = "Create JMX Connection";

	public enum ConnectionType {
		DEFAULT_JMX ("Default JMX Connection"), 
		JOLOKIA ("Jolokia Connection");
		
		private final String selection;
	    
		private ConnectionType(final String selection) {
	        this.selection = selection;
	    }

	    public String getSelection() { return this.selection; }
	}

	public JMXNewConnectionWizard() {
		super(TITTLE);
		new WaitUntil(new ShellIsAvailable(TITTLE));
	}

	public void selectConnection(ConnectionType type) {
		new DefaultTree().selectItems(new DefaultTreeItem(type.getSelection()));
	}

	public DefaultShell getShellCreateJMXConnection() {
		return new DefaultShell("Create JMX Connection");
	}

	public String getTextCreateJMXConnection() {
		return new DefaultShell("Create JMX Connection").getText();
	}

	public void clickRemoveHeaderBTN() {
		new PushButton("Remove Header").click();
	}

	public void clickEditHeaderBTN() {
		new PushButton("Edit Header").click();
	}

	public void clickAddHeaderBTN() {
		new PushButton("Add Header...").click();
	}

	public CheckBox getDoNOTVerifySSLCertificatesCHB() {
		return new CheckBox("Do NOT verify SSL Certificates (Dangerous, for local use only!!)");
	}

	public String getTextDoNOTVerifySSLCertificates() {
		return new CheckBox("Do NOT verify SSL Certificates (Dangerous, for local use only!!)").getText();
	}

	public RadioButton getPOSTRDB() {
		return new RadioButton("POST");
	}

	public String getTextPOST() {
		return new RadioButton("POST").getText();
	}

	public RadioButton getGETRDB() {
		return new RadioButton("GET");
	}

	public String getTextGET() {
		return new RadioButton("GET").getText();
	}

	public PushButton getRemoveHeaderBTN() {
		return new PushButton("Remove Header");
	}

	public String getTextRemoveHeader() {
		return new PushButton("Remove Header").getText();
	}

	public PushButton getEditHeaderBTN() {
		return new PushButton("Edit Header");
	}

	public String getTextEditHeader() {
		return new PushButton("Edit Header").getText();
	}

	public PushButton getAddHeaderBTN() {
		return new PushButton("Add Header...");
	}

	public String getTextAddHeader() {
		return new PushButton("Add Header...").getText();
	}

	public LabeledText getJolokiaURLTXT() {
		return new LabeledText("Jolokia URL: ");
	}

	public String getTextJolokiaURL() {
		return new LabeledText("Jolokia URL: ").getText();
	}

	public LabeledText getConnectionNameTXT() {
		return new LabeledText("Connection Name: ");
	}

	public String getTextConnectionName() {
		return new LabeledText("Connection Name: ").getText();
	}

	public boolean isCheckedDoNOTVerifySSLCertificatesCHB() {
		return new CheckBox("Do NOT verify SSL Certificates (Dangerous, for local use only!!)").isChecked();
	}

	public boolean isSelectedPOSTRDB() {
		return new RadioButton("POST").isSelected();
	}

	public boolean isSelectedGETRDB() {
		return new RadioButton("GET").isSelected();
	}

	public void setTextJolokiaURL(String str) {
		new LabeledText("Jolokia URL: ").setText(str);
	}

	public void setTextConnectionName(String str) {
		new LabeledText("Connection Name: ").setText(str);
	}

	public void toggleDoNOTVerifySSLCertificatesCHB(boolean choice) {
		new CheckBox("Do NOT verify SSL Certificates (Dangerous, for local use only!!)").toggle(choice);
	}

	public void togglePOSTRDB(boolean choice) {
		new RadioButton("POST").toggle(choice);
	}

	public void toggleGETRDB(boolean choice) {
		new RadioButton("GET").toggle(choice);
	}

}